﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace Team6_Algorithms.Filters
{
    /// <summary>
    /// Made by Dylan Snel
    /// </summary>
    class Invert
    {
        /// <summary>
        /// This function will invert the given image
        /// </summary>
        /// <param name="sourceImage">the input image</param>
        /// <returns>the inverted image</returns>
        public Bitmap applyFilter(Bitmap sourceImage)
        {
            Bitmap returnImage = new Bitmap(sourceImage);
            Graphics g = Graphics.FromImage(returnImage);
            ColorMatrix colorMatrix = new ColorMatrix(
                new float[][] 
                {
                    new float[] {-1, 0, 0, 0, 0},
                    new float[] {0, -1, 0, 0, 0},
                    new float[] {0, 0, -1, 0, 0},
                    new float[] {0, 0, 0, 1, 0},
                    new float[] {1, 1, 1, 0, 1}
                });
            ImageAttributes attributes = new ImageAttributes();
            attributes.SetColorMatrix(colorMatrix);
           
            g.DrawImage(sourceImage, new Rectangle(0, 0, sourceImage.Width, sourceImage.Height),
      0, 0, sourceImage.Width, sourceImage.Height, GraphicsUnit.Pixel, attributes);
            g.Dispose();
            return returnImage;
        }
    }
}

